package com.enjoy.prepare.proxy.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class HelloServiceInterceptor implements MethodInterceptor {
    /**
     * @param o           cglib生成的代理实例
     * @param method      被代理对象方法
     * @param objects     方法入参
     * @param methodProxy 代理方法
     * @return
     * @throws Throwable
     */
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {

        System.out.println("进入前置通知");

        final Object r = methodProxy.invokeSuper(o, objects);

        System.out.println("进入后置通知");
        return r;
    }
}
